package com.expense.app.admin.controller;

import com.expense.app.admin.annotation.IgnoreAuth;
import com.expense.app.admin.model.params.job.JobImportParam;
import com.expense.app.admin.model.params.job.xiao.JobsListParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import com.expense.common.util.Result;
import com.expense.app.admin.services.job.XiaoJobsServ;
import com.expense.app.admin.model.params.job.xiao.JobsParam;

/*
*
* gen controller 2019-09-24
*/
@Validated
@RestController
@RequestMapping("/xiao/job")
public class XiaoJobsCtrl {

    @Autowired
    XiaoJobsServ xiaoJobsServ;

    @PostMapping("/import")
    public Result importExcel(@RequestBody JobImportParam param) {
        return Result.success(xiaoJobsServ.importExcel(param));
    }

    @GetMapping("/list")
    public Result findList(@Validated JobsListParam param) {
        return Result.success(xiaoJobsServ.findList(param));
    }

    @IgnoreAuth
    @GetMapping("/web/list")
    public Result findWebList(@Validated JobsListParam param) {
        return Result.success(xiaoJobsServ.findList(param));
    }

    @IgnoreAuth
    @GetMapping("/web/init")
    public Result findInitList(){
        return Result.success(xiaoJobsServ.findInitList());
    }

    @GetMapping(value = "/{id}")
    public Result findDetail (@PathVariable @Min(1) Long id) {
        return Result.success(xiaoJobsServ.findDetail(id));
    }

    @PostMapping(value = "")
    public Result saveOne(@Validated @RequestBody JobsParam param) {
        return Result.success(xiaoJobsServ.saveOne(param));
    }

    @PutMapping(value = "")
    public Result update(@Validated @RequestBody JobsParam param) {
        return Result.success(xiaoJobsServ.saveOne(param));
    }

    @DeleteMapping(value = "/{id}")
    public Result deleteOne(@PathVariable @Min(1) Long id) {
        return Result.success(xiaoJobsServ.deleteOne(id));
    }
}
